/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"A884EF8C-F2B1-4ADC-9890-787D2EFF772E",variableType:4}
 */
var fChofer_aux = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"BA83C5A5-D085-4317-9748-78791BBDE2B3",variableType:4}
 */
var fCliente_aux = null;

/**
 * @type {Date}
 *
 * @properties={typeid:35,uuid:"48C97BDC-108B-44F5-ACF0-FB0327D4A098",variableType:93}
 */
var fFech_desde = null;

/**
 * @type {Date}
 *
 * @properties={typeid:35,uuid:"4D8FCF4A-5CBC-4E33-BED1-ACFC42681BE4",variableType:93}
 */
var fFecha_hasta = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"77875CA2-AA8F-4DAB-8C74-1754A3291AAC",variableType:4}
 */
var fFletero_aux = null;

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"83AB8C89-B7BC-4B41-92C4-203241B21A07"}
 */
function onAction_ira_detalle(event) {
	globals.mostrarForm("viajes_detalle_copy");   //viajes_detalle_copy
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"5E6CC19D-BC68-4055-8125-B7A99D463268"}
 * @AllowToRunInFind
 */
function onShow(firstShow, event) {
	fChofer_aux=null
	fCliente_aux=null
	fFletero_aux=null
	fFecha_hasta= new Date();
	fFech_desde=new Date();
	fFech_desde=fFech_desde.setDate (fFecha_hasta.getDate() - 30);
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"EDDFE4DF-E9BD-496F-A362-B1DE4CDD783D"}
 * @AllowToRunInFind
 */
function buscar(event) {
	// busca según los campos del header
	var found = controller.find()
	if (found == false)
	{
		globals.DIALOGS.showWarningDialog('Aviso','Error al buscar','OK');
		return
	}
	if (fChofer_aux != null)
	{
		choferes_id=fChofer_aux
	}
	if (fCliente_aux != null)
	{
		cliente_id=fCliente_aux
	}
	if (fFletero_aux != null)
	{
		fletero_id=fFletero_aux
	}
	if ((fFech_desde != null) && (fFecha_hasta != null))
		
	{	
	//Rango de Fechas //////////////////////////////
	var d1 = fFech_desde
	d1.setHours(00);
	d1.setMinutes(00);
	d1.setSeconds(00);             
	var df1 = utils.dateFormat(d1, 'dd-MM-yyyy HH:mm:ss')
	
	var d2 = fFecha_hasta
	d2.setHours(23);
	d2.setMinutes(59);
	d2.setSeconds(59);
	var df2 = utils.dateFormat(d2, 'dd-MM-yyyy HH:mm:ss')
	
	 fecha_autorizacion = df1+'...' + df2+'|dd-MM-yyyy HH:mm:ss'
	}
	var cuantos = controller.search(true,false)
	if (cuantos == 0)
	{
		globals.DIALOGS.showWarningDialog('Aviso',"No se encontraron viajes con esas características",'OK');
		return
	}
	return
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"C305A071-FEB2-4048-A415-DC82D3ED7021"}
 * @AllowToRunInFind
 */
function todos(event) {
	// muestra todos los registros
	controller.loadAllRecords()
}

/**
 * Called before the form component is rendered.
 *
 * @param {JSRenderEvent} event the render event
 *
 * @properties={typeid:24,uuid:"04A20449-1BAF-4F73-8730-31281D92D62E"}
 */
function onRender(event) {
	/** @type {JSRecord<db:/infocom/viajes>} */
	var $rcd = event.getRecord()
	if (event.isRecordSelected()) {
		event.getRenderable().fgcolor = '#FF0000';
	} 
	else 
		if ($rcd.estado_fac != 2) 
		{
			event.getRenderable().fgcolor = '#d8d7af';
		}
		else
		{
			event.getRenderable().fgcolor = '#ffffff'
		}
}
